//移除js或者css
export function removeFile(filename,filetype){
    let targetelement = (filetype === "js")? "script" :(filetype === "css")? "link" : "none";
      let targetattr = (filetype === "js")?"src" : (filetype === "css")? "href" :"none";
      let allsuspects = document.getElementsByTagName(targetelement);
      for (let i = allsuspects.length; i >= 0; i--){
          if (allsuspects[i] && allsuspects[i].getAttribute(targetattr) != null && allsuspects[i].getAttribute(targetattr).indexOf(filename)!= -1)
              allsuspects[i].parentNode.removeChild(allsuspects[i])
      }
  }
 //加载js或者css
 export function loadFile(filename, filetype){
      if (filetype === "js"){
          var fileref = document.createElement('script');
          fileref.setAttribute("type","text/javascript");
          fileref.setAttribute("src",filename);
      } else if (filetype === "css"){
          var fileref = document.createElement("link");
          fileref.setAttribute("rel","stylesheet");
          fileref.setAttribute("type","text/css");
          fileref.setAttribute("href",filename);
      }
      if (typeof fileref != "undefined") {
          document.getElementsByTagName("head")[0].appendChild(fileref);
      }
  }